package com.summer.project.system.shoyo.controller;

import com.alibaba.fastjson.JSONObject;
import com.summer.framework.web.controller.BaseController;
import com.summer.framework.web.domain.AjaxResult;
import com.summer.framework.web.page.TableDataInfo;
import com.summer.project.system.role.domain.Role;
import com.summer.project.system.shoyo.service.IShoyoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

@Controller
@RequestMapping("/system/shoyo")
public class ShoyoController extends BaseController {

    @Resource
    private IShoyoService shoyoService;


    @GetMapping("/down-by-id")
    @ResponseBody
    public AjaxResult downByGoodId(@RequestParam Integer id) throws Exception {
        shoyoService.downById(id);
        return AjaxResult.success();
    }
    @PostMapping("/downShoyoByUrl")
    @ResponseBody
    public AjaxResult downShoyoByUrl(@RequestBody JSONObject params) throws Exception {
        String url = params.getString("url");
        String site = params.getString("site");
        shoyoService.downByUrl(url, site);
        return AjaxResult.success();
    }
    @PostMapping("/downShoyoByChildUrl")
    @ResponseBody
    public AjaxResult downShoyoByChildUrl(@RequestBody JSONObject params) throws Exception {
        String url = params.getString("url");
        String site = params.getString("site");
        shoyoService.downByChildUrl(url, site);
        return AjaxResult.success();
    }
    @PostMapping("/down/shoyo")
    @ResponseBody
    public AjaxResult downShoyoJob() throws Exception {
        shoyoService.downShoyo();
        return AjaxResult.success();
    }
    @PostMapping("/down/yujian")
    @ResponseBody
    public AjaxResult downYujianJob() throws Exception {
        shoyoService.downYujian();
        return AjaxResult.success();
    }

}
